package com.marketing.tenant.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.constraints.Email;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 租户实体类
 * 对应数据库表：saas_tenant
 */
@TableName("saas_tenant")
@Schema(name = "Tenant", description = "租户信息")
public class Tenant {

    /**
     * 租户ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "租户ID", example = "1")
    private Long id;

    /**
     * 租户编码
     */
    @NotBlank(message = "租户编码不能为空")
    @Size(max = 50, message = "租户编码长度不能超过50个字符")
    @TableField("tenant_code")
    @Schema(description = "租户编码", example = "example_tenant")
    private String tenantCode;

    /**
     * 租户名称
     */
    @NotBlank(message = "租户名称不能为空")
    @Size(max = 100, message = "租户名称长度不能超过100个字符")
    @TableField("tenant_name")
    @Schema(description = "租户名称", example = "示例公司")
    private String tenantName;

    /**
     * 联系人姓名
     */
    @Size(max = 50, message = "联系人姓名长度不能超过50个字符")
    @TableField("contact_name")
    @Schema(description = "联系人姓名", example = "张三")
    private String contactName;

    /**
     * 联系电话
     */
    @Size(max = 20, message = "联系电话长度不能超过20个字符")
    @TableField("contact_phone")
    @Schema(description = "联系电话", example = "13800138000")
    private String contactPhone;

    /**
     * 联系邮箱
     */
    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100个字符")
    @TableField("contact_email")
    @Schema(description = "联系邮箱", example = "contact@example.com")
    private String contactEmail;

    /**
     * 地址
     */
    @Size(max = 200, message = "地址长度不能超过200个字符")
    @TableField("address")
    @Schema(description = "地址", example = "北京市朝阳区示例街道123号")
    private String address;

    /**
     * Logo URL
     */
    @Size(max = 255, message = "Logo URL长度不能超过255个字符")
    @TableField("logo_url")
    @Schema(description = "Logo URL")
    private String logoUrl;

    /**
     * 描述
     */
    @TableField("description")
    @Schema(description = "描述")
    private String description;

    /**
     * 状态：1-启用，0-禁用
     */
    @NotNull(message = "状态不能为空")
    @TableField("status")
    @Schema(description = "状态：1-启用，0-禁用", example = "1")
    private Integer status = 1;

    /**
     * 软删除标记：0-未删除，1-已删除
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted = 0;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    /**
     * 创建人
     */
    @TableField("created_by")
    private Long createdBy;

    /**
     * 更新人
     */
    @TableField("updated_by")
    private Long updatedBy;
    
    // 手动添加getter和setter方法
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getTenantCode() {
        return tenantCode;
    }
    
    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }
    
    public String getTenantName() {
        return tenantName;
    }
    
    public void setTenantName(String tenantName) {
        this.tenantName = tenantName;
    }
    
    public String getContactName() {
        return contactName;
    }
    
    public void setContactName(String contactName) {
        this.contactName = contactName;
    }
    
    public String getContactPhone() {
        return contactPhone;
    }
    
    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }
    
    public String getContactEmail() {
        return contactEmail;
    }
    
    public void setContactEmail(String contactEmail) {
        this.contactEmail = contactEmail;
    }
    
    public String getAddress() {
        return address;
    }
    
    public void setAddress(String address) {
        this.address = address;
    }
    
    public String getLogoUrl() {
        return logoUrl;
    }
    
    public void setLogoUrl(String logoUrl) {
        this.logoUrl = logoUrl;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public Integer getStatus() {
        return status;
    }
    
    public void setStatus(Integer status) {
        this.status = status;
    }
    
    public Integer getDeleted() {
        return deleted;
    }
    
    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
    
    public Long getCreatedBy() {
        return createdBy;
    }
    
    public void setCreatedBy(Long createdBy) {
        this.createdBy = createdBy;
    }
    
    public Long getUpdatedBy() {
        return updatedBy;
    }
    
    public void setUpdatedBy(Long updatedBy) {
        this.updatedBy = updatedBy;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Tenant tenant = (Tenant) o;
        return Objects.equals(id, tenant.id) &&
                Objects.equals(tenantCode, tenant.tenantCode) &&
                Objects.equals(tenantName, tenant.tenantName) &&
                Objects.equals(contactName, tenant.contactName) &&
                Objects.equals(contactPhone, tenant.contactPhone) &&
                Objects.equals(contactEmail, tenant.contactEmail) &&
                Objects.equals(address, tenant.address) &&
                Objects.equals(logoUrl, tenant.logoUrl) &&
                Objects.equals(description, tenant.description) &&
                Objects.equals(status, tenant.status) &&
                Objects.equals(deleted, tenant.deleted) &&
                Objects.equals(createTime, tenant.createTime) &&
                Objects.equals(updateTime, tenant.updateTime) &&
                Objects.equals(createdBy, tenant.createdBy) &&
                Objects.equals(updatedBy, tenant.updatedBy);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, tenantCode, tenantName, contactName, contactPhone, contactEmail, address, logoUrl, description, status, deleted, createTime, updateTime, createdBy, updatedBy);
    }

    @Override
    public String toString() {
        return "Tenant{" +
                "id=" + id +
                ", tenantCode='" + tenantCode + '\'' +
                ", tenantName='" + tenantName + '\'' +
                ", contactName='" + contactName + '\'' +
                ", contactPhone='" + contactPhone + '\'' +
                ", contactEmail='" + contactEmail + '\'' +
                ", address='" + address + '\'' +
                ", logoUrl='" + logoUrl + '\'' +
                ", description='" + description + '\'' +
                ", status=" + status +
                ", deleted=" + deleted +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", createdBy=" + createdBy +
                ", updatedBy=" + updatedBy +
                '}';
    }
}